package com.jswlw.controller.distributor;

import com.jswlw.controller.distributor.adapter.CustomAdapter;
import com.jswlw.entity.biz.OrderInfo;
import com.jswlw.entity.biz.RepairInfo;
import com.jswlw.service.biz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Controller
@RequestMapping("/distributor/custom")
public class DistributorCustomController {

    @Autowired
    DistributorService distributorService;

    @Autowired
    CustomAdapter customAdapter;

    @Autowired
    DevInfoService devInfoService;

    @Autowired
    DevFilterService devFilterService;

    @Autowired
    OrderInfoService orderInfoService;

    @Autowired
    RepairInfoService repairInfoService;

    @RequestMapping("index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/index");
       // modelAndView.addObject("devUsers", customAdapter.devUsers());
        return modelAndView;
    }

    @RequestMapping("customDetail")
    public ModelAndView customDetail(@RequestParam("id") Integer id) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customDetail");
        //modelAndView.addObject("info", customAdapter.devUserInfo(id));
        return modelAndView;
    }

    @RequestMapping("customMessageDetail")
    public ModelAndView customMessageDetail() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customMessageDetail");
        return modelAndView;
    }

    @RequestMapping("customCenter")
    public ModelAndView customCenter() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customCenter");
        return modelAndView;
    }

    @RequestMapping("customDevInfo")
    public ModelAndView customDevInfo(@RequestParam("devId") String devId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customDevInfo");
        modelAndView.addObject("info", devInfoService.find4Id(devId));
        return modelAndView;
    }

    @RequestMapping("customFilterInfo")
    public ModelAndView customFilterInfo(@RequestParam("devSn") String devSn) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customFilterInfo");
        modelAndView.addObject("filterInfo", devFilterService.find4Id(1));
        return modelAndView;
    }

    @RequestMapping("customOrderInfo")
    public ModelAndView customOrderIndex(@RequestParam("userId") Integer userId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customOrderInfo");
        OrderInfo filter = new OrderInfo();
        filter.setUserId(1);
        modelAndView.addObject("orders", orderInfoService.queryList(filter));
        return modelAndView;
    }

    @RequestMapping("customRepairInfo")
    public ModelAndView customRepairIndex(@RequestParam("userId") Integer userId) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("distributor/custom/customRepairInfo");
        RepairInfo filter = new RepairInfo();
        filter.setUserId(userId);
        modelAndView.addObject("repairs", repairInfoService.queryList(filter));
        return modelAndView;
    }
}
